﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public enum RoomType
{
	def,
	boss,
	hide,
	stair_up,
	stair_down,
}

public class Room
{
	public RoomType type;
	public Vector2 pos;
	public int width;
	public int height;
	public Vector2 currentStart;
	public Vector2 currentEnd;
	public List<Door> doors;

	public Room(int w, int h, RoomType t = RoomType.def)
	{
		width = w;
		height = h;
		doors = new List<Door>();
		type = t;
		if (t == RoomType.def) 
		{
			doors.Add(new Door(new Vector2(Mathf.RoundToInt(Random.Range(1, width - 1)), 0),this));
			doors.Add(new Door(new Vector2(Mathf.RoundToInt(Random.Range(1, width - 1)), height - 1),this));
			doors.Add(new Door(new Vector2(0, Mathf.RoundToInt(Random.Range(1, height - 1))),this));
			doors.Add(new Door(new Vector2(width - 1, Mathf.RoundToInt(Random.Range(1, height - 1))),this));
		}
		else if (t == RoomType.stair_up || t == RoomType.stair_down)
		{
			doors.Add(new Door(new Vector2(0, 0),this));
		}
		SetPos(new Vector2(0f, 0f));
	}
	public void SetPos(Vector2 Pos)
	{
		pos = Pos;
		currentStart = pos;
		currentEnd = new Vector2(width,height) + pos;
		for (int i = doors.Count - 1; i >= 0; i--) 
		{
			doors[i].x += pos.x;
			doors[i].y += pos.y;
		}
	}
}
